package com.dayuan.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dayuan.bean.MerchantInfo;
import com.dayuan.dao.MerchantInfoMapper;

@Service
public class MerchantInfoService {
	@Resource
	private MerchantInfoMapper merchantInfoMapper;

	/**
	 * 
	 * @param 通过商家名模糊查询详细信息
	 * @return
	 */
	public List<MerchantInfo> selectMerchantByParam(MerchantInfo record, int startIndex, int pageNum) {
		Map map = new HashMap();
		map.put("shopName", record.getShopName());
		map.put("startIndex", startIndex);
		map.put("pageNum", pageNum);
		List<MerchantInfo> list = merchantInfoMapper.selectByParam(map);
		return list;
	}

	/**
	 * 通过ID查询商铺名
	 * 
	 * @param id
	 * @return
	 */
	public MerchantInfo selectByPrimaryKey(Integer id) {
		MerchantInfo merchantInfo = merchantInfoMapper.selectByPrimaryKey(id);
		return merchantInfo;
	}

	/**
	 * 通过UID查询商铺名
	 * 
	 * @param id
	 * @return
	 */
	public MerchantInfo selectByUid(Integer uId) {
		MerchantInfo merchantInfo = merchantInfoMapper.selectByUid(uId);
		return merchantInfo;
	}

	/**
	 * 得到商家总数
	 * 
	 * @return
	 */
	public int selectCount(MerchantInfo record) {

		return merchantInfoMapper.selectCount(record);

	}

	/**
	 * 
	 * @param mi
	 *            通过分页查询得到商家信息
	 * @return
	 */
	public List<MerchantInfo> selectMerchantByLimit(int startIndex, int pageNum) {
		List<MerchantInfo> list = merchantInfoMapper.selectMerchantByLimit(startIndex, pageNum);
		return list;
	}

	/**
	 * 根据uid查询商家信息
	 * 
	 * @param uid
	 * @return
	 */
	public MerchantInfo sellerMerchantInfo(Integer uId) {
		MerchantInfo merchantInfo = merchantInfoMapper.selectByUid(uId);
		return merchantInfo;
	}

	/**
	 * 插入商家信息
	 * @param merchantInfo
	 * @return
	 */
	public int insterMerchanInfo(MerchantInfo merchantInfo){
		return merchantInfoMapper.insert(merchantInfo);
	}
	
	/**
	 * 跟新商家信息
	 * @param merchantInfo
	 * @return
	 */
	public int updateMerchanInfo(MerchantInfo merchantInfo){
		return merchantInfoMapper.updateByPrimaryKeySelective(merchantInfo);
	}
	
	
}
